home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
UTILITY1
/
CB200.ZIP
/
CALEND.PA_
/
CALEND.PA
Wrap
Text File
|
1993-09-01
|
10KB
|
361 lines
Library Calend;
{ Calend Add-In for the clySmic Icon Bar. (C) 1992, 1993 by clySmic Software.
All Rights reserved. }
{define Debug}
{$ifndef Debug}
{$R-,I-,D-,L-,S-,V-,W-,G+}
{$endif}
{$C MOVEABLE PRELOAD DISCARDABLE}
Uses
WinTypes,WinProcs,Strings,WinDOS,TPWTools;
{$R CALEND}
{$I ADD-IN.INC}
Const
ShowDOW : Boolean = True;
CLBVer : VerString = '2.00';
Var
Yr,Mon,Day,DOW : Word;
IWDate,INIFile : Array [0..80] of Char;
USDateFormat : Boolean;
{$D Calend Add-In. (C) 1992, 1993 by clySmic Software. All Rights Resv'd.}
{-----------------------------------------------}
{ --- Utility Procedures --- }
Function CenterTx(DC : HDC; Tx : PChar; Rect : TRect) : Integer;
Var
Width,WinX,StrtX : Integer;
Begin
{ Ask Windows for the total pixel length of the string & calc starting X }
Width := LoWord(GetTextExtent(DC,Tx,StrLen(Tx)));
{ Get total x width of window - don't add 1! }
WinX := (Rect.Right - Rect.Left);
{ Calculate centered starting posn }
StrtX := ((WinX - Width) Div 2) + Rect.Left;
{ Return }
CenterTx := StrtX;
End {CenterTx};
{-----------------------------------------------}
Procedure FormIWDate;
Const
MonthName : Array [1..12] of PChar =
('January','February','March','April','May','June',
'July','August','September','October','November','December');
Days : array [0..6] of PChar =
('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
Var
StrDay,StrYr : Array [0..4] of Char;
Begin
GetDate(Yr,Mon,Day,DOW);
Str(Day,StrDay);
Str(Yr,StrYr);
If USDateFormat
Then Begin
{ US date fmt }
StrCopy(IWDate,Days[DOW]);
StrCat(IWDate,', ');
StrCat(IWDate,MonthName[Mon]);
StrCat(IWDate,' ');
StrCat(IWDate,StrDay);
StrCat(IWDate,', ');
StrCat(IWDate,StrYr);
End
Else Begin
{ European date fmt }
StrCopy(IWDate,Days[DOW]);
StrCat(IWDate,', ');
StrCat(IWDate,StrDay);
StrCat(IWDate,' ');
StrCat(IWDate,MonthName[Mon]);
StrCat(IWDate,' ');
StrCat(IWDate,StrYr);
End;
End {FormIWDate};
{-----------------------------------------------}
{ --- Perform Add-In's initialization --- }
Function AddInInit(CurVer : PChar) : InitResult; Export;
Begin
{ Version check }
If StrComp(CurVer,CLBVer) <> 0
Then AddInInit := InitNotOk
Else AddInInit := InitOk;
{ Point at our INI file, which is in our home dir }
StrPCopy(INIFile,HomeDir);
StrCat(INIFile,'CALEND.INI');
{ Flush INI file so we can edit it }
WritePrivateProfileString(Nil,Nil,Nil,INIFile);
{ Get display mode }
USDateFormat := Boolean(GetPrivateProfileInt('Settings',
'USDateFormat',
0,
INIFile));
End {AddInInit};
{-----------------------------------------------}
{ --- Paint on the button (Clysbar does the background) --- }
Procedure AddInPaint(Wnd : HWnd; DC : HDC; Pressed : Boolean); Export;
Const
MonthName : Array [1..12] of PChar =
('JAN','FEB','MAR','APR','MAY','JUN',
'JUL','AUG','SEP','OCT','NOV','DEC');
Days : array [0..6] of PChar =
('SUN','MON','TUE','WED','THU','FRI','SAT');
Var
ShadRect,Rect : TRect;
NumFont,OldFont,SmlFont : HFont;
Tx : Array[0..128] of Char;
StrYr,StrDay : Array [0..4] of Char;
StrtX,StrtY : Integer;
TheIcon : HIcon;
Begin
GetClientRect(Wnd,Rect);
{ Calc location of icon }
StrtX := ((Rect.Right - Rect.Left) - GetSystemMetrics(sm_cxIcon)) Div 2;
StrtY := ((Rect.Bottom - Rect.Top) - GetSystemMetrics(sm_cyIcon)) Div 2;
{ Draw turning page if pressed }
If Pressed
Then Begin
TheIcon := LoadIcon(hInstance,'turning');
DrawIcon(DC,StrtX,StrtY,TheIcon);
Exit;
End;
{ Draw "page" icon }
TheIcon := LoadIcon(hInstance,'calend');
DrawIcon(DC,StrtX,StrtY,TheIcon);
{ Get date info }
GetDate(Yr,Mon,Day,DOW);
Str(Day,StrDay);
Str(Yr,StrYr);
{ Create small font for the month/day/year }
SmlFont :=
CreateFont(9, { Height }
0,0,0, { Width, left 2 right, normal orientation }
400, { Weight }
0,0,0, { Italic, underlined, or strikeout }
0, { ANSI char set }
0, { Reserved precision field }
0, { Default clipping }
Proof_Quality, { Quality }
ff_Roman Or Variable_Pitch,
'Small Fonts');
{ Create large font for the day number }
NumFont :=
CreateFont(17, { Height }
0,0,0, { Width, left 2 right, normal orientation }
700, { Weight }
0,0,0, { Italic, underlined, or strikeout }
0, { ANSI char set }
0, { Reserved precision field }
0, { Default clipping }
Proof_Quality, { Quality }
ff_Roman Or Variable_Pitch,
'Times New Roman');
{ Setup for day number }
OldFont := SelectObject(DC,NumFont);
SetBkMode(DC,Transparent);
{ Draw lg day number's shadow }
SetTextColor(DC,RGB(128,128,128));
ShadRect := Rect;
OffsetRect(ShadRect,2,1);
DrawText(DC,StrDay,StrLen(StrDay),ShadRect,
dt_Center or dt_VCenter or dt_SingleLine);
{ Draw lg day number }
SetTextColor(DC,RGB(0,0,0));
OffsetRect(Rect,1,0);
DrawText(DC,StrDay,StrLen(StrDay),Rect,
dt_Center or dt_VCenter or dt_SingleLine);
{ Setup for other info }
SelectObject(DC,SmlFont);
{ Draw month name }
StrCopy(Tx,MonthName[Mon]);
SetTextColor(DC,RGB(255,0,0));
OffsetRect(Rect,-1,0);
TextOut(DC,CenterTx(DC,Tx,Rect),StrtY + 1,Tx,StrLen(Tx));
{ Either year or doy }
If ShowDOW
Then Begin
{ Display day of week }
StrCopy(Tx,Days[DOW]);
SetTextColor(DC,RGB(0,0,128));
OffsetRect(Rect,-1,0);
TextOut(DC,CenterTx(DC,Tx,Rect),StrtY + 22,Tx,StrLen(Tx));
End
Else Begin
{ Display year }
StrCopy(Tx,StrYr);
SetTextColor(DC,RGB(128,0,128));
TextOut(DC,CenterTx(DC,Tx,Rect),StrtY + 22,Tx,StrLen(Tx));
End;
{ Clean up }
SelectObject(DC,OldFont);
DeleteObject(SmlFont);
DeleteObject(NumFont);
End {AddInPaint};
{-----------------------------------------------}
{ --- Tell Clysbar what kind of timer we need --- }
Function AddInTimerNeeded : Integer; Export;
Begin
AddInTimerNeeded := ait_Slow;
End {AddInTimerNeeded};
{-----------------------------------------------}
{ --- Proc called when timer expires, perform timed duties --- }
Procedure AddInTimerTick(Wnd : HWnd; DC : HDC); Export;
Var
TimerDay : Word;
Begin
{ Check for a date change }
GetDate(Yr,Mon,TimerDay,DOW);
{ If different, repaint window }
If TimerDay <> Day
Then AddInPaint(Wnd,DC,False);
End {AddInTimerTick};
{-----------------------------------------------}
{ --- Proc called when button pressed --- }
Procedure AddInPressed(Wnd : HWnd; DC : HDC); Export;
Begin
{ Toggle the "show day-of-week" indicator when button pressed }
ShowDOW := Not ShowDOW;
AddInPaint(Wnd,DC,False);
End {AddInPressed};
{-----------------------------------------------}
{ --- Exit processing for Add-In --- }
Procedure AddInExit; Export;
Begin
End {AddInExit};
{-----------------------------------------------}
{ --- Clysbar queries Add-In about itself --- }
Procedure AddInAbout(Str1,Str2 : PChar;
Var TheIcon : HIcon;
Var TitleCol,TxCol,BkCol : TColorRef); Export;
Begin
StrCopy(Str1,'Calend V2.00');
StrCopy